/**
 * @author: Abid Hussain
 */
exports.GAPromotionsModel = Core.Class.subclass({
	classname: 'GAPromotionsModel',
	initialize: function(){
		this._showmulti = null;
		this._cursor = null;
		this._promotionModelArray = [];
	},
	parsePromotions: function(promotionsObject){
		this._showmulti = promotionsObject['@showmulti'];
		this._cursor = promotionsObject['@cursor'];
		var promotion = promotionsObject.promotion;
		var isArray = this._isArray(promotion); 
		if(isArray){
			this._length = (typeof promotions != 'undefined' && promotion != null) ? promotion.length : 0; 
			if(this._length > 0){ 		
				for(var i=0; i<this._length; i++){
					this._parse(promotion[i]);
				}
			}
		}
		else{
			this._parse(promotion);
		}
	},
	_parse: function(promotion){
		var promotionModel = new GAPromotionModel();
		promotionModel.parse(promotion);
		this._promotionModelArray.push(promotionModel);
	},
	_isArray: function(variable) {
		return (variable.constructor == Array);
	},
	getShowMulti: function(){
		return this._showmulti;
	},
	getCursor: function(){
		return this._cursor;
	},
	getPromotionModelArray: function(){
		return this._promotionModelArray;
	},
	destroy: function(){
		for(var i=0; i<this._length; i++){
			this._promotionModelArray[i].destroy();
			this._promotionModelArray[i] = null;
		}
		this._promotionModelArray = null;
		this._length = null;
		this._showmulti = null;
		this._cursor = null;
	}
});